

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <#include "../../include/layui.ftl" />
    <#include "../../include/pTable.ftl" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <form  id="queryForm">
                <input type="hidden" id="className" name="className" value="${className!}" />
                <input type="hidden" id="modleName" name="modleName" value="${modleName!}" />
                <div class="layui-form-item">
                  <#--  <div class="layui-inline">
                        <label class="layui-form-label">登录帐号</label>
                        <div class="layui-input-block">
                            <input type="text" name="account" placeholder="请输入" autocomplete="off" class="layui-input">
                            <input type="hidden" name="account_searchType" value="like">
                        </div>
                    </div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label">昵称</label>
                        <div class="layui-input-block">
                            <input type="text" name="nickName" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">手机号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="mobile" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <div class="layui-card-body">

            <table id="lay-table" lay-filter="lay-table"></table>
            <script type="text/html" id="toolbar">
            </script>
        </div>
    </div>
</div>
<script>
    var $ = null,layer = null,$tables = null,table = null;
    layui.config({
        base: '${path}/plug-in/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','tables','layers','view'],function () {
        var tables = layui.tables,
            view = layui.view,
            layers = layui.layers;
        $ = layui.$,layer = layui.layer,table = layui.table;
        var parmer = {
            url:'/console/user/rewrite/list',
            cols:[[
                    {field:"companyName",width:'25%',title:"部门名称"}
                    ,{field:"account",width:'10%',title:"登录帐号"}
                    ,{field:"nickName",width:'10%',title:"昵称"}
                    ,{field:"mobile",width:'10%',title:"手机号码"}
                    ,{field:"roleName",width:'10%',title:"角色"}
                    ,{field:"count",width:'10%',title:"剩余次数"}
                    ,{field:"userStatus",width:'8%',title:"用户状态",templet: function(d){
                        if(d.userStatus == '0'){
                            return '<span style="color:green;">正常</span>';
                        }else{
                            return '<span style="color: #c00;">禁用</span>';
                        }
                    }},
                    {field:"decoder",width:"15%",title:"推荐码",templet:function (row) {
                        if(row.decoder == null || row.decoder == ''){
                            return "<a href='javascript:void(0);' onclick='addDecoder(\""+row.id+"\")'>点击生成</a>";
                        }else{
                            return row.decoder;
                        }
                    }}
                    ,{field:"integral",width:'10%',title:"积分"}
                ]]
        };
        $tables = tables.renderTable(parmer);

        //头工具栏事件
        table.on('toolbar(lay-table)', function(obj){
            switch(obj.event){
                case '01':
                    layers.add({
                        area:['500px', '390px']
                    });
                    break;
                case '02':
                    layers.edit({
                        area:['500px', '280px'],
                        data: p.data
                    });
                    break;
                case '03':
                    layers.delete({url:'/console/user/rewrite/delete',data:p.data});
                    break;
                case '05':
                    var where = $("#queryForm").serializeObject();
                    $tables.reload({
                        where: where,
                        text: {none: '暂无数据！'}
                    });
                    break;
                case '08':
                    layers.delete({
                        url:"/console/user/rewrite/resetPwd",
                        data:p.data,
                        msg:"重置密码后为登录帐号，确认重置吗？"
                    });
                    break;
                case '09':
                    if($.isEmptyObject(p.data)){
                        layer.msg("请先选择一条数据");
                        return;
                    }
                    if(p.data.userStatus == "0"){
                        layers.delete({
                            url:"/console/user/rewrite/prohibit",
                            data:{id:p.data.id,userStatus:"1"},
                            msg:"确定禁用该账号吗？"
                        });
                    }else{
                        layers.delete({
                            url:"/console/user/rewrite/prohibit",
                            data:{id:p.data.id,userStatus:"0"},
                            msg:"确定恢复该账号吗？"
                        });
                    }
                    break;
                case '25':
                    layers.edit({
                        content:'/console/user/rewrite/toConfig',
                        data:p.data,
                        area:['600px', '530px']
                    });
                    break;
            };
        });
    });
    function addDecoder(id) {
        $.post("/console/user/rewrite/addDecoder",{id:id},function (res) {
            if(res.flag){
                var where = $("#queryForm").serializeObject();
                $tables.reload({
                    where: where,
                    text: {none: '暂无数据！'}
                });
            }else{
                layer.msg(res.msg);
            }
        });
    }
</script>
</body>
</html>